package net.dodoman.refrence;

public class Test2 {
	public static int t1(int n) {
		n = 10;
		return n;
	}

	public static String t2(String s) {
		s = "123";
		return s;
	}

	public static void t3(int[] array) {
		// 创建新的数组并赋值
		int[] newArray = new int[array.length];
		// 数据拷贝
		System.arraycopy(array, 0, newArray, 0, array.length);
		newArray[0] = 2;
	}

	public static Object t4(Object obj) {
		obj = new Object();
		return obj;
	}

	public static void main(String[] args) {
		int m = 5;
		// 重新赋值
		m = t1(m);
		System.out.println(m);
		String s1 = "abc";
		// 重新赋值
		s1 = t2(s1);
		System.out.println(s1);
		int[] arr = { 1, 2, 3, 4 };
		t3(arr);
		System.out.println(arr[0]);
		Object obj1 = new Object();
		Object obj2=obj1;
		System.out.println(obj2==obj1);
		System.out.println(obj1.hashCode()+"   "+obj2.hashCode());
		System.out.println(obj1.hashCode());
		obj1 = t4(obj1);
		System.out.println(obj2==obj1);
		System.out.println(obj1.hashCode());
	}
}
